from django.conf import settings
from django.conf.urls import url
from django.conf.urls.static import static
from django.contrib import admin
from django.urls import path, include
from django.views.static import serve
from rest_framework.documentation import include_docs_urls

urlpatterns = [
    path('adminbyme/', admin.site.urls),
    path('', include(('Main.urls', 'Main'), namespace='main')),
    path('fkl/', include(('fkl_salary.urls', 'fkl_salary'), namespace='fklsalary')),
    path('bed/', include(('ImageBed.urls', 'ImageBed'), namespace='imagebed')),
    # 在项目的根 urls.py 中添加扩展url和媒体文件url,用于mdeditor的编辑和图片保存:
    path('mdeditor/',include('mdeditor.urls')),

    # 由于django会在debug=True时对静态文件进行自动路由，所以需要在不同DEBUG状态下进行不同配置
    url(r'^static/(?P<path>.*)$', serve,
        {'document_root': settings.STATIC_ROOT}, name='static'),



]

if settings.DEBUG:
    # static files (images, css, javascript, etc.)
    urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
    urlpatterns.append(
        path(r'docs/', include_docs_urls(title='API文档'))
    )

